﻿<?php 

	set_time_limit(0);

	$a = new api();

	$a->postGet();



	class api{

		function postGet(){



			switch ($_POST['type']) {

				case '1':

					echo self::insertDb('youjuTell','(link_url,title,name,start_date,images,city)',$_POST['phones']);

					break;

				case '2':

					echo self::insertDb('wxgongzhonghaophone','(showname,mobile,last_event_time,appName,last_worker,talk_time)',$_POST['phones']);
					
					break;

				case '3':

					echo self::getAppnames();
					
					break;
				case '4':

					echo self::getChongFuTell($_POST['phones'],$_POST['riqi']);

					break;
				
				default:
					# code...
					break;
			};



		}


		function insertDb($tableName,$filed,$tells){   //更新优居数据库提交时间

       
	        $qure="INSERT IGNORE INTO ".$tableName."  ".$filed."  VALUES ".$tells;
	        // echo $qure;

	        $host='localhost';
	        $user='root';
	        $password='root';
	        $database='weizandata';
	        $link=mysqli_connect($host, $user, $password, $database);
	        $link->query("set names utf8");
	        $result=mysqli_query($link, $qure);
	        $json = json_encode(array(
	                "code"=>0,
	                "msg"=>'提交成功',
	                "data"=>$result ),
	                JSON_UNESCAPED_UNICODE);
	        
	        
	        mysqli_close($link);

	        return $json;

	    }


	    function getAppnames(){

	        $qure="SELECT appName FROM wxgongzhonghaophone GROUP BY appName;";

	        $host='localhost';
	        $user='root';
	        $password='root';
	        $database='weizandata';
	        $link=mysqli_connect($host, $user, $password, $database);
	        $link->query("set names utf8");
	        $result=mysqli_query($link, $qure);
	        $arr=mysqli_fetch_all($result, 1);
	        $json = json_encode(array(
	                "code"=>0,
	                "msg"=>'获取成功',
	                "data"=> $arr ),
	                JSON_UNESCAPED_UNICODE);
	        
	        
	        mysqli_close($link);

	       return $json;

    	}

    	function getChongFuTell($phones,$riqi){

	        $qure="SELECT start_date,link_url FROM youjutell WHERE link_url IN ".$phones." AND start_date <> '".$riqi."';";
	        $host='localhost';
	        $user='root';
	        $password='root';
	        $database='weizandata';
	        $link=mysqli_connect($host, $user, $password, $database);
	        $link->query("set names utf8");
	        $result=mysqli_query($link, $qure);
	        $arr=mysqli_fetch_all($result, 1);
	        $json = json_encode(array(
	                "code"=>0,
	                "msg"=>'获取成功',
	                "count"=>count($arr),
	                "data"=> $arr ),
	                JSON_UNESCAPED_UNICODE);
	        
	        
	        mysqli_close($link);

	       return $json;

    	}




	}

















 ?>